package cn.edu.scau.cmi.chensixiao.domain;

import java.util.Objects;

public class Student implements java.io.Serializable {

	  public Student() {
	  }

	  private Long id;
	  private Teacher teacher;
	  private String name;

	  public Long getId() {
	    return this.id;
	  }

	  public void setId(Long id) {
	    this.id = id;
	  }

	  public Teacher getTeacher() {
		  if(teacher!=null) {
			  return this.teacher;
		  }else {
			  return null;
		  }
	  }

	  public void setTeacher(Teacher teacher) {
	    this.teacher = teacher;
	  }

	  public String getName() {
	    return this.name;
	  }

	  public void setName(String name) {
	    this.name = name;
	  }
	  
	  @Override
	  public boolean equals(Object student) {
		  if(student instanceof Student && this.id==((Student)student).id) {
			  return true;
		  }
		  return false;
		  
	  }
	  
	  @Override
	  public int hashCode(){
		  return Objects.hash(id,name);
	  }
	  
	  @Override
	  public String toString() {
		  StringBuilder result = new StringBuilder();
		  result.append("学号： "+ this.getId()+"\t\t");
		  result.append("姓名： "+this.getName()+"\t\t");
		  result.append("导师： ");
		  if(this.getTeacher()!=null) {
			  result.append(this.getTeacher().getName() + "\n");
		  }else {
			  result.append("\n");
		  }
		  return result.toString();
	  }
	  
}
